package com.marry.multidatasource.service;

import com.github.pagehelper.PageHelper;
import com.marry.multidatasource.mapper.bd.OwnancaseMapper;
import com.marry.multidatasource.model.RequestItem;
import com.marry.multidatasource.model.bd.RightOrProof;
import com.marry.multidatasource.util.Cardhelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author ml
 * @create 2018-01-08--10:20
 */
@Service
public class OwnacaseService {
    @Autowired
    private OwnancaseMapper ownancaseMapper;

    private static final Integer pagesize=5;

    @Cacheable(value = "addCache",key = "#requestItem.getConame()+#requestItem.getPage()+'_selectRightsOrProofByName'")
    public List<RightOrProof> getRightsOrProofByName(RequestItem requestItem){
        System.out.println("----------没走缓存");

        PageHelper.startPage(requestItem.getPage(),pagesize);
        return ownancaseMapper.selectRightsOrProofByNameLcCn(requestItem);
    }

    public Integer selectCountByNameLcCn(RequestItem requestItem){
        return ownancaseMapper.selectCountByNameLcCn(requestItem);

    }

    public List<RightOrProof> getRightsByLocationOrCqzh(RequestItem requestItem) {
        PageHelper.startPage(requestItem.getPage(),pagesize);
        return ownancaseMapper.selectRightsOrProofByNameLcCn(requestItem);

    }

    /**
     *
     * @param requestItem
     * @return
     */
    public List<RightOrProof> getRightsByCertno(RequestItem requestItem) {

        return ownancaseMapper.selectRightsOrProofByCertno(requestItem);



    }

    /**
     *
     * @param requestItem
     * @return
     */
    public Integer selectCountByCertno(RequestItem requestItem) {

        return ownancaseMapper.selectCountByCertno(requestItem);

    }
}
